<template>
  <div id="app">
    <router-view></router-view>
  </div>
</template>

<script setup>
import {onMounted} from "vue";
import router from "@/router";
import {authAccess} from "@/api";
import CryptoJS from 'crypto-js';
import axios from "axios";
import segmentation from "../public/configuration";
onMounted(()=> {


  setTimeout(() => {
    // /api/
    setInterval(()=>{
      // axios.get('/v1/heartbeat')
    },segmentation.time)
    if (sessionStorage.getItem('access_token') == null && window.location.href.split('access_token=')[1]) {
      sessionStorage.setItem('access_token',window.location.href.split('access_token=')[1].split('&&onceKey=')[0])
      sessionStorage.setItem('onceKey',window.location.href.split('access_token=')[1].split('onceKey=')[1])
      let  app_sercert = 'c383875e44dc07bba55e456d826f66cadb1db806a8e3b818eb1bd8e079dd57e3'
      let data = {
        accessToken:sessionStorage.getItem('access_token'),
        onceKey:sessionStorage.getItem('onceKey'),
        appKey:'Adversarial Examples on Images'
      }
      // MD5(access_token+app_key+app_secret+onceKey)
      data.signature = CryptoJS.MD5(data.accessToken + data.appKey + app_sercert + data.onceKey).toString();
      authAccess(data).then((res)=>{
        if(res.code == 200){
           sessionStorage.setItem('subSystems',JSON.stringify(res.data.subSystems))
          sessionStorage.setItem('id',JSON.stringify(res.data.id))
         setTimeout(()=>{
           router.push('/Mainpage/AdvIntro')
         })
        }
      })
    }
  },1000)
})
</script>

<style>
.nav{
  background: rgb(44, 57, 81);
}
</style>
